package com.chif.goingplus.utils;

import com.chif.goingplus.service.EChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class CharServiceUtils {

    @Autowired
    private EChartService eChartService;
    private static CharServiceUtils charServiceUtils;

    @PostConstruct //通过@PostConstruct实现初始化bean之前进行的操作
    public void init() {
        charServiceUtils = this;
        charServiceUtils.eChartService=this.eChartService;
        // 初使化时将已静态化的testService实例化
    }


    public static String getchartData(String chartId){
        String chartData=null;
        switch (chartId){
            case "trend":chartData= charServiceUtils.eChartService.getTrendData();break;
            case "rank":chartData= charServiceUtils.eChartService.getRankData();break;
            case "seller":chartData= charServiceUtils.eChartService.getSellerOrder();break;
            case "hot":chartData= charServiceUtils.eChartService.getHotData();break;
            case "stock":chartData= charServiceUtils.eChartService.getStockData();break;
            case "map":chartData= charServiceUtils.eChartService.getMapData();break;
            case "count":chartData= charServiceUtils.eChartService.getOrderAndIncomeCount();break;
        }
        return chartData;
    }
}
